<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller {

	public function index()
	{
		$this->load->helper('form');
		$this->load->library('form_validation');
		
		$rules = array(
				array(
					'field' => 'signup_firstname',
					'label' => 'First Name',
					'rules' => 'trim|required'
				),
				array(
					'field' => 'signup_lastname',
					'label' => 'Last Name',
					'rules' => 'trim|required'
				),
				array(
					'field' => 'signup_username',
					'label' => 'User Name',
					'rules' => 'trim|required|min_length[5]|max_length[12]|xss_clean|callback_username_check'
				),
				array(
					'field' => 'signup_password',
					'label' => 'Password',
					'rules' => 'trim|required|min_length[8]|max_length[32]|matches[signup_password_confirm]'
				),
				array(
					'field' => 'signup_password_confirm',
					'label' => 'Password Confirmation',
					'rules' => 'trim|required'
				),
			);
		$this->form_validation->set_rules($rules);
		
		if ($this->form_validation->run() == FALSE)
		{
			$this->load->view('login');
		}
		else
		{
			$this->load->view('login_success');
		}
	}
	
	function username_check($username)
	{
		if ($username == 'r0nald11')
		{
			$this->form_validation->set_message('username_check', 'The %s field can not be the word "r0nald11"');
			return FALSE;
		}
		else
		{
			return TRUE;
		}
	}
}

/* End of file login.php */
/* Location: ./application/controllers/login.php */